<?php

namespace App\Http\Controllers\Api\Client;

use App\Http\Controllers\Controller;
use App\Models\Api\browse;
use App\Models\House;
use Illuminate\Http\Request;

class BrowseController extends Controller
{
    //浏览及录操作

    //获取用户的房源
    public function getUserBrowse(Request $request){
        //$request->user_id;
        $uid=$request->input('id');
        if (empty($uid)){
            return ['code'=>30304,'msg'=>'登录失效','data'=>''];
        }
        //收藏
        $titles = browse::where('uid',$uid)->pluck('fid');
        if (empty($titles)){
            return ['code'=>30204,'msg'=>'浏览记录为空','data'=>''];
        }
        $titles= $titles->toArray();
        //收藏的房源列表
        $collectList = House::whereIn('id', $titles)->get();
        return ['code'=>30200,'msg'=>'查询成功','data'=>$collectList];
    }
}
